﻿using LunchListCore.Base;
using LunchListCore.Entities;
using LunchListCore.Interfaces.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace LunchList.ViewModels
{
    public class EventsViewModel : PageViewModelBase, IValidatableObject
    {
		public IList<IEvent> EventListPast { get; set; }
		public IList<IEvent> EventListFuture { get; set; }

        [Required]
        public string EventName { get; set; }

        [Required]                
        public DateTime EventDate { get; set; }

        public string UserId { get; set; }

        public string UserName { get; set; }


        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            var field = new[] { "EventDate" };
            DateTime resultDate;
            if (!DateTime.TryParse(EventDate.ToString(), out resultDate))
            {
                yield return new ValidationResult("Event Date must be a valid datetime value.", field);
            }
            if (EventDate < DateTime.Now)
            {
                yield return new ValidationResult("Event can not be in the past.", field);
            }


        }
    }

    


}